/**
 * 
 */
package view;

import javax.swing.JOptionPane;

import rmiClient.Client_IMPL;

/**
 * @author arthur
 * 
 */
public class ThreadCheckElectionResult implements Runnable {

	MainFrame mf;
	Client_IMPL clientLocal;

	public ThreadCheckElectionResult(MainFrame mf, Client_IMPL clientLocal) {
		super();
		this.mf = mf;
		this.clientLocal = clientLocal;
	}

	/**
	 * @see java.lang.Runnable#run()
	 */
	@Override
	public void run() {
		while (!clientLocal.getElectionWithoutDiffusionResult().isEmpty()) {
			String[] result = clientLocal.getElectionWithoutDiffusionResult()
					.get(0);
			clientLocal.getElectionWithoutDiffusionResult().remove(0);
			JOptionPane.showMessageDialog(mf, "Le gagnant est le client : "
					+ result[0]);

			// start the receiver with the result[1]
			// on fait un thread pour que l'attente de la video ne soit pas
			// bloquante
			// voir classe Receive ci dessous
			String argv[] = new String[1];
			argv[0] = result[1];
			Receive r = new Receive(argv);
			r.start();
		}
	}

}
